package org.example.dept.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 天天向上 （john.yi@qq.com）
 * @data 2020/8/31.
 */
@RestController
@RequestMapping("/depts")
public class DeptController {
    @Value("${server.port}")
    private String port;
    @GetMapping("/{id}")
    public String byId(@PathVariable Integer id) {
        if (id==1) {
            return "市场部" + port;
        }
        return "开发部" + port;
    }
    @GetMapping("/obj/{id}")
    public Dept byId2(@PathVariable Integer id) {
        Dept dept = new Dept();
        dept.setId(id);
        dept.setDeptName(id < 10 ? "开发部" : "市场部");
        return dept;
    }
    @GetMapping("/hello")
    public String hello(String username) {
        return "dept hello " + username;
    }
}
